﻿#include <iostream>
#include <string>
using namespace std;

void replaceAll(string& s, const string& oldVal, const string& newVal) 
{
	size_t found = 0;
	while ((found = s.find(oldVal)) != string::npos) {
		s.replace(found, oldVal.size(), newVal);
	}
}

int main() 
{
	string text = "tho thur thom";
	replaceAll(text, "tho", "though");
	replaceAll(text, "thru", "through");
	cout << text << endl; // 输出应该是 "though through thoughm"

	return 0;
}
